﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="ViewQuestion.aspx.vb" Inherits="BooksReviewApp.ViewQuestions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="aside2">
       <br />
        <br />
        <br />
        <h3>
        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
               
                    <%# "Chapter : " & Eval("Chapter")  %>
            </ItemTemplate>
        </asp:Repeater>
            </h3>
        <br />
        <br />
        <asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                Asked By •
                <asp:HyperLink ID="HyperLink2" runat="server" Text='<%# Eval("Questioner")%>' NavigateUrl='<%# Eval("Questioner", "Profile.aspx?Bibliophile={0}")%>'
                    ForeColor="Red" Font-Bold="True" CssClass="red" Font-Size="Smaller">
                </asp:HyperLink>
                <br />
                Category • 
                <asp:HyperLink ID="Hl_Category" runat="server" Text='<%# Eval("Category")%>' NavigateUrl='<%# Eval("Category", "BooksByCategory.aspx?Category={0}")%>'
                    ForeColor="#009999" Font-Bold="False" Font-Size="Small">
                </asp:HyperLink>
                <br />
                Sub Category •
                <asp:HyperLink ID="Hl_SubCategory" runat="server" Text='<%# Eval("SubCategory")%>' NavigateUrl='<%# Eval("SubCategory", "BooksBySubCategory.aspx?SubCategory={0}")%>'
                    ForeColor="Orange" Font-Bold="False" Font-Size="Small">
                </asp:HyperLink>
                <br />
 
            </ItemTemplate>
        </asp:Repeater>
        <div class="Justified">
            <br />
            <h3><asp:Repeater ID="Repeater5" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
               
                    <%# "Question : " & Eval("Question_Number")  %>
            </ItemTemplate>
        </asp:Repeater></h3>
            <br />
            <br />
            <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <%# Eval("Question_Text")%>
                </ItemTemplate>
            </asp:Repeater>
            <br />
            <br />     
        </div>

        <asp:PlaceHolder runat="server" ID="ph_Solution">
            <h5>Solution Provided</h5>
            <br />
            <br />
            <div class="Justified">
                <asp:Repeater ID="Repeater6" runat="server" DataSourceID="SqlDataSource3">
                <ItemTemplate>
                    <%# Eval("Solution")%>
                </ItemTemplate>
            </asp:Repeater>
            <asp:Label ID="lbl_Solution" runat="server"></asp:Label>
            <br />
            <br />     
            </div>
        </asp:PlaceHolder>

        <h5>More Questions for this book</h5>
        <br />
        <br />
        <asp:Label ID="lbl_Questions" runat="server"></asp:Label>
        <asp:Repeater ID="Repeater7" runat="server" DataSourceID="SqlDataSource2">

            <ItemTemplate>
                <a id="RepeaterStyle" href="ViewQuestion.aspx?Question=<%# Eval("ID") %>">
                    <%# "Chapter : " & Eval("Chapter") & " Question : " & Eval("Question_Number") %></a>
            </ItemTemplate>
        </asp:Repeater>
        <br />
        <br />
        <h5>Was this helpful?</h5>
        <br />
        <br />

        <asp:Button ID="btn_VoteQuestion" runat="server" Text="Vote" CssClass="m-btn purple" />
                    <asp:Repeater ID="rpt_Votes" runat="server" DataSourceID="SqlDataSource4">
                        <ItemTemplate>
                            •
                            <asp:Label ID="lbl_Views" runat="server" Text='<%# Eval("TotalVotes") %>' CssClass="myButton" />
                        </ItemTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                        ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [TotalVotesPerQuestion] WHERE ([ID] = @Question_FK)">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="Question_FK" QueryStringField="Question" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
    </div>
    <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <h2>
                    <%# Eval("BookName") %></h2>
            </ItemTemplate>
        </asp:Repeater>
    <div class="mainDiv2">
        <br />
        <div class="CommentsDetailsArea">
            <h3>
                    <%= getTotalSolutions() %></h3>
                <table>
                    <tr>
                        <td>
                            Title
                        </td>
                        <td>
                            <asp:TextBox ID="tb_Title" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator
                                ID="RequiredFieldValidator1" runat="server" ControlToValidate="tb_Title" CssClass="field-validation-error"
                                ErrorMessage="*" ValidationGroup="CommentGroup"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="tb_Title"
                                ErrorMessage="*" ValidationExpression="[^\s]+" CssClass="field-validation-error" ValidationGroup="CommentGroup" />
                            <asp:RegularExpressionValidator ID="regexpName" runat="server"
                                ErrorMessage="This expression does not validate." ControlToValidate="tb_Title"
                                ValidationExpression="^[a-zA-Z'.\s]{1,40}$" CssClass="field-validation-error" ValidationGroup="CommentGroup" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Solution
                        </td>
                        <td>
                            <asp:TextBox ID="tb_Comment" runat="server" TextMode="MultiLine" Height="75px" Width="300px"></asp:TextBox><asp:RequiredFieldValidator
                                ID="RequiredFieldValidator2" runat="server" ControlToValidate="tb_Comment" CssClass="field-validation-error"
                                ErrorMessage="*" ValidationGroup="CommentGroup"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                </table>
                <asp:Button ID="btn_Solution" runat="server" CommandArgument="0"
                    Text="Add Solution" ValidationGroup="CommentGroup" CssClass="m-btn blue" />
                <hr />
                <div id="ContentWraper">
                    <asp:Literal ID="CommentsLtr" runat="server"></asp:Literal></div>
                <br />
    </div>
    
        

        
    </div>
    


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                        ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT * FROM [Books_Questions] WHERE ([QuestionsID] = @QuestionsID)">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="QuestionsID" QueryStringField="Question" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                            ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT DISTINCT * FROM [Questions] WHERE ([Book_FK] =  @Book_FK AND ID != @QuestionsID) ORDER BY Chapter DESC, Question_Number DESC">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="QuestionsID" QueryStringField="Question" Type="Int32" />
                                <asp:QueryStringParameter Name="Book_FK" QueryStringField="Book_FK" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BooksReviewDBConnectionString1 %>"
                            ProviderName="<%$ ConnectionStrings:BooksReviewDBConnectionString1.ProviderName %>" SelectCommand="SELECT DISTINCT * FROM [Books_Questions] WHERE ([QuestionsID] =  @QuestionsID AND ProvidesSolution = 1)">
                            <SelectParameters>
                                <asp:QueryStringParameter Name="QuestionsID" QueryStringField="Question" Type="Int32" />
                            </SelectParameters>
                        </asp:SqlDataSource>
</asp:Content>
